﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAO;
using System.Data;
using DTO;

namespace BUS
{
    public class PhieuChi_BUS
    {
        private static PhieuChi_BUS m_instance = null;

        public static PhieuChi_BUS Instance
        {
            get
            {
                if (m_instance == null)
                    m_instance = new PhieuChi_BUS();
                return m_instance;
            }
        }

        /// <summary>
        ///   lay ma phieu chi max
        /// </summary>
        /// 

        public string LayMaPhieuChi()
        {
            string result = "";
            DataTable dt = PhieuChi_DAO.Instance.LayMaPhieuChi();
            DataRowCollection list = dt.Rows;
            if (list.Count == 0)
            {
                return null;
            }
            DataRow dr = list[0];
            result = (string)dr["MaPhieuChi"];
            return result;
        }

        /// <summary>
        ///   them phieu chi moi
        ///   
        /// </summary>
        /// 

        public bool ThemPhieuChiMoi(PhieuChi_DTO _item)
        {
            return PhieuChi_DAO.Instance.ThemPhieuChi(_item.MaPhieuChi, _item.NgayChi, _item.TongTien);
        }
    }
}
